import {
    getdiseaseList
} from "@/api/department";
export default {
    props: {
        placeholder: {
            type: String,
            default: "请选择",
        },
        isDisabled: {
            type: Boolean,
            default: false,
        },
    },
    components: {},
    data() {
        return {
            diseaseList: [], //病种列表
            loading: false,//加载中
            diseaseCodes: "",
        }
    },
    methods: {
        reset(){
            this.diseaseCodes="";
            this.diseaseList=[];
        },
        //获取疾病列表
        getDiseaseList(query) {
            let data = {
                page: 1,
                limit: 999,
                name: query,
            };
            getdiseaseList(data)
                .then((res) => {
                    this.loading = false;
                    if (res.code == 200 && res.data) {
                        let arr = [];
                        res.data.records.map((item) => {
                            arr.push({
                                value: item.code,
                                label: item.name,
                                id:item.name+'-'+item.code
                            });
                        });
                        this.diseaseList = arr;
                        // this.diseaseCodes = this.code;
                        // this.$emit("handelDiseaseList", this.diseaseList);
                    }
                })
                .finally(() => { });
        },
        handelEvent(value) {
            this.$emit("handelEvent", value);
            if(value==""){
                this.diseaseList = [];
            }
        },
        //远程搜索
        remoteMethod(query) {
            if (query !== '') {
                this.loading = true;
                this.getDiseaseList(query)
            } else {
                this.diseaseList = [];
            }
        }
    },
}